Component({
    properties: {
        active: {
            type: [ Array, Number, String ],
            value: {}
        }
    },
    relations: {
        "./collapse-item": {
            type: "child",
            linked: function(i) {
                this.data.children.push(i);
            },
            linkChanged: function(i) {
                this.data.children.splice(active.indexOf(i), 1);
            },
            unlinked: function(i) {}
        }
    },
    data: {
        children: []
    },
    observers: {
        active: function() {
            this.data.children.forEach(function(i) {
                i.updateExpanded();
            });
        }
    },
    methods: {
        switch: function(i) {
            var e = JSON.parse(JSON.stringify(this.data.active));
            -1 != e.indexOf(i) ? e.splice(e.indexOf(i), 1) : e.push(i), this.triggerEvent("change", e);
        }
    }
});